<div class="bjui-pageContent">
    <form action="/admin/logistics/line-edit" data-toggle="ajaxform" data-options="{closeCurrent:true,tabid:'logistics-line-list-navtab'}">
        <div class="bjui-row">

            <label class="row-label">专线名称</label>
            <div class="row-input">
                <input type="text" name="title" value="{{$info->title}}" data-rule="required">
            </div>

            <label class="row-label">联系人</label>
            <div class="row-input">
                <input type="text" name="contact_name" value="{{$info->contact_name}}" data-rule="required">
            </div>

            <label class="row-label">联系电话</label>
            <div class="row-input">
                <input type="text" name="contact_mobile" value="{{$info->contact_mobile}}" data-rule="required">
            </div>

            <label class="row-label">选择省</label>
            <div class="row-input">
                <select name="province_id" id="province_id" ygtProvince data-toggle="selectpicker" data-rule="required">
                    <option value="">请选择</option>
                    @foreach ($provinceList as $val)
                        @if ($info->province_id == $val['provinceID'])
                            <option value="{{$val['provinceID']}}" selected>{{$val['province']}}</option>
                        @else
                            <option value="{{$val['provinceID']}}">{{$val['province']}}</option>
                        @endif
                    @endforeach
                </select>
            </div>
            <label class="row-label">选择市</label>
            <div class="row-input">
                <select name="city_id" id="city_id" data-rule="required" ygtCity>
                    <option value="">请选择</option>
                    @if (!empty($info->city_id) && $info->city_id>0)
                        <option value="{{$info->city_id}}" selected>{{$info->city_name}}</option>
                    @endif
                </select>
            </div>
            <label class="row-label">选择县</label>
            <div class="row-input">
                <select name="area_id" id="area_id" data-rule="required">
                    <option value="">请选择</option>
                    @if (!empty($info->area_id) && $info->area_id>0)
                        <option value="{{$info->area_id}}" selected>{{$info->area_name}}</option>
                    @endif
                </select>
            </div>
            <label class="row-label">详细地址</label>
            <div class="row-input">
                <input type="text" name="address" value="{{$info->address}}">
            </div>

            <label class="row-label"></label>
            <div class="row-input">
                <input type="hidden" name="is_submit" id="is_submit" value="1">
                <input type="hidden" name="id" value="{{$info->id}}">
                <input type="hidden" name="logistics_id" value="{{$logisticsId}}">
                <button type="submit" class="btn-default">保存</button>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $('*[ygtProvince]').on('change',function(){
            var value       = $(this).val();
            ygtAddressCity(value);
        });
        $('*[ygtCity]').on('change',function(){
            var value       = $(this).val();
            ygtAddressArea(value);
        });
    });
    function ygtAddressCity(value)
    {
        var url     = 'admin/ajax/address';
        var obj     = {type:2,value:value};
        var html    = '<option value="">请选择</option>';
        if(value!=''){
            $.post(url,obj,function(data){
                var chtml    = html;
                $.each(data,function(i,n){
                    chtml    += '<option value="'+n.cityID+'">'+n.city+'</option>';
                })
                $('#city_id').html(chtml);
                $('#area_id').html(html);
            },'json');
        }else{
            $('#city_id').html(html);
            $('#area_id').html(html);
        }
    }
    function ygtAddressArea(value)
    {
        var url     = 'admin/ajax/address';
        var obj     = {type:3,value:value};
        var html    = '<option value="">请选择</option>';
        if(value!=''){
            $.post(url,obj,function(data){
                $.each(data,function(i,n){
                    html    += '<option value="'+n.areaID+'">'+n.area+'</option>';
                })
                $('#area_id').html(html);
            },'json');
        }else{
            $('#area_id').html(html);
        }
    }
</script>